//实例化编辑器
var um = UM.getEditor('NotifyText');
var um2 = UM.getEditor("updateNotifyText");

$(function () {
    $("#submitNotify").click(function () {
        $("#addNotifyModal").attr("action","/setting/addNotify").submit();
    })
})

$(function () {
    //点击获取当前行的ID
    $(".badge-info").click(function () {
        var UpdateID = $(this).parents("tr").find(".yc").text();
        //通过ID获取通知信息
        $.ajax(
            {
                url: "/setting/getNotify",
                type: "POST",
                async:false,
                dataType: "json",
                data: {NID: UpdateID},
                success: function (result) {
                    ReadNotify(result);
                }
            });
    })
    $(".badge-danger").click(function () {
        //获取ID
        var DeleteID = $(this).parents("tr").find(".yc").text();
        if(confirm("确认删除?") == true){
            //进行ajax请求
            $.ajax(
                {
                    url: "/setting/deleteNotifyByID",
                    type: "POST",
                    async:false,
                    dataType: "json",
                    data: {NID: DeleteID},
                    success: function (result) {
                        window.location.reload();
                    }
                });
        }
    })

    $("#UpdateSubmit").click(function () {
        $("#updateNotifyModal").attr("action","/setting/addNotify").submit();
    })

})
function ReadNotify(JsonResult) {
    console.log(JsonResult);
    $("#UpdateTitle").val(JsonResult["title"]);
    um2.setContent(JsonResult["text"]);
    $("#UpdateID").val(JsonResult["id"]);
}